package com.yourvote.action;

import com.yourvote.dao.DistrictDao;
import com.yourvote.dao.impl.DistrictDaoImpl;
import com.yourvote.model.District;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: pavlo.fedyna
 * Date: 10/24/12
 * Time: 6:53 PM
 * To change this template use File | Settings | File Templates.
 */
public class DistrictAction extends BaseAction{
    private String district;
    private List<District> districts;
    private DistrictDao districtDao = new DistrictDaoImpl();
    private District districtObj = new District();

    public String execute(){
        addActionMessage("!!!");
        districtObj.setNumber(Integer.parseInt(district));
        districtDao.add(districtObj);
        districts = districtDao.getAll();
        return SUCCESS;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public District getDistrictObj() {
        return districtObj;
    }

    public void setDistrictObj(District districtObj) {
        this.districtObj = districtObj;
    }

    public DistrictDao getDistrictDao() {
        return districtDao;
    }

    public void setDistrictDao(DistrictDao districtDao) {
        this.districtDao = districtDao;
    }

    public List<District> getDistricts() {
        return districts;
    }

    public void setDistricts(List<District> districts) {
        this.districts = districts;
    }
}
